home *** CD-ROM | disk | FTP | other *** search
/ C & C++ Multimedia Cyber Classroom / C and C++ Multimedia Cyber Classroom (Prentice Hall) (1998).iso / cpphtp2 / code.jar / code / ch11 / fig11_28.txt < prev    next >
Text File  |  1998-02-27  |  973b  |  28 lines

  1. 1   // Fig. 11.28: fig11_28.cpp 
  2. 2   // Demonstrating the flags member function.
  3. 3   #include <iostream.h>
  4. 4   
  5. 5   int main()
  6. 6   {
  7. 7      int i = 1000;
  8. 8      double d = 0.0947628;
  9. 9   
  10. 10     cout << "The value of the flags variable is: "
  11. 11          << cout.flags()
  12. 12          << "\nPrint int and double in original format:\n"
  13. 13          << i << '\ ' << d << "\n\n";
  14. 14     long originalFormat =  
  15. 15             cout.flags( ios::oct | ios::scientific );
  16. 16     cout << "The value of the flags variable is: "
  17. 17          << cout.flags()
  18. 18          << "\nPrint int and double in a new format\n"
  19. 19          << "specified using the flags member function:\n"
  20. 20          << i << '\ ' << d << "\n\n";
  21. 21     cout.flags( originalFormat );
  22. 22     cout << "The value of the flags variable is: "
  23. 23          << cout.flags() 
  24. 24          << "\nPrint values in original format again:\n"
  25. 25          << i << '\ ' << d << endl;
  26. 26     return 0;
  27. 27  }
  28.